define(["jquery", "easy-admin"], function ($, ea) {
 
    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'management.treehouse/index',
        add_url: 'management.treehouse/add',
        edit_url: 'management.treehouse/edit',
        delete_url: 'management.treehouse/delete',
        export_url: 'management.treehouse/export',
        modify_url: 'management.treehouse/modify',
        price_url: 'management.treehouse/price',
       
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar:['refresh',  [{
                    text: '添加',
                    url: init.add_url,
                    method: 'open',
                    auth: 'add',
                    class: 'layui-btn layui-btn-normal layui-btn-sm',
                    icon: 'fa fa-plus ',
                    extend: 'data-full="true"',
                }],],
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'id'},
                    {field: 'title', title: '树屋编号'},
                   {field: 'image', minWidth: 80, title: '树屋图', search: false, templet: ea.table.image,search:false},
                    {width: 250, title: '操作', templet: ea.table.tool,
                    operat: [
                        [{
                            text: '编辑',
                            field:'id',
                            url: init.edit_url,
                            method: 'open',
                            auth: 'edit',
                            class: 'layui-btn layui-btn-success layui-btn-xs',
                            extend: 'data-full="true"',
                        },
                        {
                            title:'确定删除？',
                            text: '删除',
                            field:'id',
                            url: init.delete_url,
                            method: 'delete',
                            class: 'layui-btn layui-btn-danger layui-btn-xs',
                        },
                    ]
                ]
                    },
                ]],
            });

            ea.listen();
        },
  
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        price: function () {
            ea.listen();
        },
    };
    return Controller;
});